package com.isprint.jslx.lcc.redis;

import com.jfinal.kit.Prop;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.redis.RedisPlugin;

import java.util.Date;

/**
 * Created by ydw on 2017/7/14.
 */
public class RedisProperties {
    private static Prop redis = PropKit.use("config/redis.properties");
    public static String host=redis.get("host","localhost");
    public static Integer port=redis.getInt("port",6379);
    public static String password=redis.get("password",null);
    public static boolean onBorrow=false;
    public static boolean onReturn=false;
    public static Integer maxIdle=200;
    public static Integer maxTotal=300;
    public static Integer timeout=redis.getInt("timeout",2*60*60);
    public static String cacheName=redis.get("cacheName","redis");
    public static Integer database=redis.getInt("database",2);

    /**
     * 获取redis插件
     * @return
     */
    public static RedisPlugin  getRedisPlugin(){
        RedisPlugin redisPlugin=null;

        if (password == null) {
            redisPlugin = new RedisPlugin(cacheName, host, port, timeout, password, database);
        }else {
            redisPlugin=new RedisPlugin(cacheName,host,port,timeout);
        }
        return redisPlugin;
    }
}
